Change in openvpn[master]: dco_linux: validate tun interface before fetching stats
A message that is not in the archive (sent off-list or not yet received): gerrit.1756824907000.I40c11864745cc1619cb9cbf490b168f90feb5eac@...2715...
Attention is currently required from: flichtenheld, plaisthos.
Hello plaisthos, flichtenheld,
I'd like you to do a code review.
Please visit
http://gerrit.openvpn.net/c/openvpn/+/1166?usp=email
to review the following change.
Change subject: dco_linux: validate tun interface before fetching stats
......................................................................
dco_linux: validate tun interface before fetching stats
If dco_get_peer_stats() is called with an uninitialized c->c1.tuntap it results in a segfault. This issue happens when a client who has not connected to any server:
- has --management and exits,
- has --management and a management interface client issues either bytecount or status or
- if SIGUSR2 is sent to it.
Add a check to ensure the tun interface was set up before attempting to retrieve peer statistics.
---
M src/openvpn/dco_linux.c
1 file changed, 7 insertions(+), 0 deletions(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/66/1166/1
src/openvpn/dco_linux.c +7 -0
@@ -1139,6 +1139,8 @@static int dco_get_peer (dco_context_t *dco,int peer_id,const bool raise_sigusr1_on_err) { +ASSERT (dco); +/* peer_id == -1 means "dump all peers", but this is allowed in MP mode only. * If it happens in P2P mode it means that the DCO peer was deleted and we * can simply bail out
@@ -1182,6 +1184,11 @@int dco_get_peer_stats (struct context *c,const bool raise_sigusr1_on_err) { +if (!tuntap_defined (c->c1.tuntap)) + { +return -1 ; + } +return dco_get_peer (&c->c1.tuntap->dco, c->c2.tls_multi->dco_peer_id, raise_sigusr1_on_err); }
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1166?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I40c11864745cc1619cb9cbf490b168f90feb5eac
Gerrit-Change-Number: 1166
Gerrit-PatchSet: 1
Gerrit-Owner: ralf_lici <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-MessageType: newchange
Attention is currently required from: flichtenheld, plaisthos, ralf_lici.
cron2 has posted comments on this change. ( http://gerrit.openvpn.net/c/openvpn/+/1166?usp=email )
Change subject: dco_linux: validate tun interface before fetching stats
......................................................................
Patch Set 1: Code-Review+2
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1166?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I40c11864745cc1619cb9cbf490b168f90feb5eac
Gerrit-Change-Number: 1166
Gerrit-PatchSet: 1
Gerrit-Owner: ralf_lici <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Attention: ralf_lici <[email protected]...>
Gerrit-Comment-Date: Tue, 02 Sep 2025 15:08:11 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment
PATCH 1/1 dco_linux: validate tun interface before fetching stats
In reply to a message not in the archiveFrom: Ralf Lici <[email protected]...>
If dco_get_peer_stats() is called with an uninitialized c->c1.tuntap it results in a segfault. This issue happens when a client who has not connected to any server:
- has --management and exits,
- has --management and a management interface client issues either bytecount or status or
- if SIGUSR2 is sent to it.
Add a check to ensure the tun interface was set up before attempting to retrieve peer statistics.
---
This change was reviewed on Gerrit and approved by at least one developer. I request to merge it to master.
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1166
This mail reflects revision 1 of this Change.
Acked-by according to Gerrit (reflected above):
Gert Doering <[email protected]...>
src/openvpn/dco_linux.c +7 -0
@@ -1139,6 +1139,8 @@static int dco_get_peer (dco_context_t *dco,int peer_id,const bool raise_sigusr1_on_err) { +ASSERT (dco); +/* peer_id == -1 means "dump all peers", but this is allowed in MP mode only. * If it happens in P2P mode it means that the DCO peer was deleted and we * can simply bail out
@@ -1182,6 +1184,11 @@int dco_get_peer_stats (struct context *c,const bool raise_sigusr1_on_err) { +if (!tuntap_defined (c->c1.tuntap)) + { +return -1 ; + } +return dco_get_peer (&c->c1.tuntap->dco, c->c2.tls_multi->dco_peer_id, raise_sigusr1_on_err); }
Attention is currently required from: flichtenheld, plaisthos, ralf_lici.
cron2 has posted comments on this change. ( http://gerrit.openvpn.net/c/openvpn/+/1166?usp=email )
Change subject: dco_linux: validate tun interface before fetching stats
......................................................................
Patch Set 1: Code-Review-2
(2 comments)
Patchset:
PS1:
breaks BYTECOUNT on Linux+DCO for me (tuntap_defined() always returns FALSE)
File src/openvpn/dco_linux.c:
http://gerrit.openvpn.net/c/openvpn/+/1166/comment/a34991d7_2990cc7c :
PS1, Line 1187: if (!tuntap_defined(c->c1.tuntap))
this does not work, as it checks
``` return tt && tt->fd >= 0; ```
and with DCO, tt->fd is not set, so this totally breaks counters in client mode with DCO. It does not crash, though.
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1166?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I40c11864745cc1619cb9cbf490b168f90feb5eac
Gerrit-Change-Number: 1166
Gerrit-PatchSet: 1
Gerrit-Owner: ralf_lici <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Attention: ralf_lici <[email protected]...>
Gerrit-Comment-Date: Tue, 02 Sep 2025 15:46:44 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment
Attention is currently required from: flichtenheld, plaisthos, ralf_lici.
Hello cron2, flichtenheld, plaisthos,
I'd like you to reexamine a change. Please visit
http://gerrit.openvpn.net/c/openvpn/+/1166?usp=email
to look at the new patch set (#2).
Change subject: dco_linux: validate tun interface before fetching stats
......................................................................
dco_linux: validate tun interface before fetching stats
If dco_get_peer_stats() is called with an uninitialized c->c1.tuntap it results in a segfault. This issue happens when a client who has not connected to any server:
- has --management and exits,
- has --management and a management interface client issues either bytecount or status or
- if SIGUSR2 is sent to it.
Add a check to ensure the tun interface was set up before attempting to retrieve peer statistics.
---
M src/openvpn/dco_linux.c
1 file changed, 7 insertions(+), 0 deletions(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/66/1166/2
src/openvpn/dco_linux.c +7 -0
@@ -1139,6 +1139,8 @@static int dco_get_peer (dco_context_t *dco,int peer_id,const bool raise_sigusr1_on_err) { +ASSERT (dco); +/* peer_id == -1 means "dump all peers", but this is allowed in MP mode only. * If it happens in P2P mode it means that the DCO peer was deleted and we * can simply bail out
@@ -1182,6 +1184,11 @@int dco_get_peer_stats (struct context *c,const bool raise_sigusr1_on_err) { +if (!c->c1.tuntap || c->c1.tuntap->dco.ifindex ==0 ) + { +return -1 ; + } +return dco_get_peer (&c->c1.tuntap->dco, c->c2.tls_multi->dco_peer_id, raise_sigusr1_on_err); }
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1166?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I40c11864745cc1619cb9cbf490b168f90feb5eac
Gerrit-Change-Number: 1166
Gerrit-PatchSet: 2
Gerrit-Owner: ralf_lici <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Attention: ralf_lici <[email protected]...>
Gerrit-MessageType: newpatchset
Attention is currently required from: flichtenheld, plaisthos, ralf_lici.
cron2 has posted comments on this change. ( http://gerrit.openvpn.net/c/openvpn/+/1166?usp=email )
Change subject: dco_linux: validate tun interface before fetching stats
......................................................................
Patch Set 2: Code-Review+2
(1 comment)
Patchset:
PS2:
``` >HOLD:Waiting for hold release:0 bytecount 1 SUCCESS: bytecount interval changed hold release SUCCESS: hold release succeeded >BYTECOUNT:4111,2888 >BYTECOUNT:4219,2996 >BYTECOUNT:4327,3104 ```
no crash *and* counters!
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1166?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I40c11864745cc1619cb9cbf490b168f90feb5eac
Gerrit-Change-Number: 1166
Gerrit-PatchSet: 2
Gerrit-Owner: ralf_lici <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Attention: ralf_lici <[email protected]...>
Gerrit-Comment-Date: Tue, 02 Sep 2025 16:45:05 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment
PATCH v2 1/1 dco_linux: validate tun interface before fetching stats
In reply to a message not in the archiveFrom: Ralf Lici <[email protected]...>
If dco_get_peer_stats() is called with an uninitialized c->c1.tuntap it results in a segfault. This issue happens when a client who has not connected to any server:
- has --management and exits,
- has --management and a management interface client issues either bytecount or status or
- if SIGUSR2 is sent to it.
Add a check to ensure the tun interface was set up before attempting to retrieve peer statistics.
---
This change was reviewed on Gerrit and approved by at least one developer. I request to merge it to master.
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1166
This mail reflects revision 2 of this Change.
Acked-by according to Gerrit (reflected above):
Gert Doering <[email protected]...>
src/openvpn/dco_linux.c +7 -0
@@ -1139,6 +1139,8 @@static int dco_get_peer (dco_context_t *dco,int peer_id,const bool raise_sigusr1_on_err) { +ASSERT (dco); +/* peer_id == -1 means "dump all peers", but this is allowed in MP mode only. * If it happens in P2P mode it means that the DCO peer was deleted and we * can simply bail out
@@ -1182,6 +1184,11 @@int dco_get_peer_stats (struct context *c,const bool raise_sigusr1_on_err) { +if (!c->c1.tuntap || c->c1.tuntap->dco.ifindex ==0 ) + { +return -1 ; + } +return dco_get_peer (&c->c1.tuntap->dco, c->c2.tls_multi->dco_peer_id, raise_sigusr1_on_err); }
[Openvpn-devel] [PATCH applied] Re: dco_linux: validate tun interface before fetching stats
Tested this on ubuntu 20.04 + DCO - --client + --management-hold, connect to mgmt, "bytecount 1", "hold release", boom, SIGSEGV.
v1 looked correct, but checked the wrong variables, so "no SIGSEGV, but no counters at all anymore", not so good either ;-) - v2 fixes that, no crash *and* working counters. With proper timing. So really getting there, after a day staring at manage.c...
Your patch has been applied to the master branch.
commit 14ced61eef89797e606c3b7600adc4da83a336f4
Author: Ralf Lici Date: Tue Sep 2 18:45:15 2025 +0200
dco_linux: validate tun interface before fetching stats
Signed-off-by: Ralf Lici <[email protected]...>
Acked-by: Gert Doering <[email protected]...>
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg32768.html
Signed-off-by: Gert Doering <[email protected]...>--
kind regards,
Gert Doering
cron2 has uploaded a new patch set (#3) to the change originally created by ralf_lici. ( http://gerrit.openvpn.net/c/openvpn/+/1166?usp=email )
The following approvals got outdated and were removed:
Code-Review+2 by cron2
Change subject: dco_linux: validate tun interface before fetching stats
......................................................................
dco_linux: validate tun interface before fetching stats
If dco_get_peer_stats() is called with an uninitialized c->c1.tuntap it results in a segfault. This issue happens when a client who has not connected to any server:
- has --management and exits,
- has --management and a management interface client issues either bytecount or status or
- if SIGUSR2 is sent to it.
Add a check to ensure the tun interface was set up before attempting to retrieve peer statistics.
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg32768.html
---
M src/openvpn/dco_linux.c
1 file changed, 7 insertions(+), 0 deletions(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/66/1166/3
src/openvpn/dco_linux.c +7 -0
@@ -1139,6 +1139,8 @@static int dco_get_peer (dco_context_t *dco,int peer_id,const bool raise_sigusr1_on_err) { +ASSERT (dco); +/* peer_id == -1 means "dump all peers", but this is allowed in MP mode only. * If it happens in P2P mode it means that the DCO peer was deleted and we * can simply bail out
@@ -1182,6 +1184,11 @@int dco_get_peer_stats (struct context *c,const bool raise_sigusr1_on_err) { +if (!c->c1.tuntap || c->c1.tuntap->dco.ifindex ==0 ) + { +return -1 ; + } +return dco_get_peer (&c->c1.tuntap->dco, c->c2.tls_multi->dco_peer_id, raise_sigusr1_on_err); }
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1166?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I40c11864745cc1619cb9cbf490b168f90feb5eac
Gerrit-Change-Number: 1166
Gerrit-PatchSet: 3
Gerrit-Owner: ralf_lici <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-MessageType: newpatchset
cron2 has submitted this change. ( http://gerrit.openvpn.net/c/openvpn/+/1166?usp=email )
Change subject: dco_linux: validate tun interface before fetching stats
......................................................................
dco_linux: validate tun interface before fetching stats
If dco_get_peer_stats() is called with an uninitialized c->c1.tuntap it results in a segfault. This issue happens when a client who has not connected to any server:
- has --management and exits,
- has --management and a management interface client issues either bytecount or status or
- if SIGUSR2 is sent to it.
Add a check to ensure the tun interface was set up before attempting to retrieve peer statistics.
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg32768.html
---
M src/openvpn/dco_linux.c
1 file changed, 7 insertions(+), 0 deletions(-)
src/openvpn/dco_linux.c +7 -0
@@ -1139,6 +1139,8 @@static int dco_get_peer (dco_context_t *dco,int peer_id,const bool raise_sigusr1_on_err) { +ASSERT (dco); +/* peer_id == -1 means "dump all peers", but this is allowed in MP mode only. * If it happens in P2P mode it means that the DCO peer was deleted and we * can simply bail out
@@ -1182,6 +1184,11 @@int dco_get_peer_stats (struct context *c,const bool raise_sigusr1_on_err) { +if (!c->c1.tuntap || c->c1.tuntap->dco.ifindex ==0 ) + { +return -1 ; + } +return dco_get_peer (&c->c1.tuntap->dco, c->c2.tls_multi->dco_peer_id, raise_sigusr1_on_err); }
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1166?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I40c11864745cc1619cb9cbf490b168f90feb5eac
Gerrit-Change-Number: 1166
Gerrit-PatchSet: 3
Gerrit-Owner: ralf_lici <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-MessageType: merged